namespace utils {
    std::vector<std::string> GetFilesWithExt(const std::string& folderPath,
        const std::string& ext) { // GetFilesWithExt("/path/to/folder/", "ext");
        std::vector<std::string> filePaths;
        std::string searchPath = folderPath + "/*" + ext;
        WIN32_FIND_DATA fileData;
        HANDLE hFind = FindFirstFile(searchPath.c_str(), &fileData);
        if (hFind == INVALID_HANDLE_VALUE) return filePaths;
        do {
            if (!strcmp(fileData.cFileName, ".")) continue;
            if (!strcmp(fileData.cFileName, "..")) continue;
            if (fileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue;
            std::string filePath = folderPath + "/" + fileData.cFileName;
            // std::string filePath = folderPath;
            // if (folderPath.back() != '/') filePath += "/";
            // filePath += fileData.cFileName;
            filePaths.push_back(filePath);
        } while (FindNextFile(hFind, &fileData) != 0);
        return filePaths;
    }
    bool crtDir(const TCHAR* path) {
        DWORD fileAttributes = GetFileAttributes(path);
        if (fileAttributes == INVALID_FILE_ATTRIBUTES) {
            return CreateDirectory(path, NULL);
        } else return fileAttributes & FILE_ATTRIBUTE_DIRECTORY;
    }
    bool dirExists(const std::string &path) {
        DWORD fileAttributes = GetFileAttributes(path.c_str());
        if (fileAttributes == INVALID_FILE_ATTRIBUTES) return 0;
        return (fileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
    }
    bool fileExists(const std::string &path) {
        DWORD fileAttributes = GetFileAttributes(path.c_str());
        if (fileAttributes == INVALID_FILE_ATTRIBUTES) return 0;
        return !(fileAttributes & FILE_ATTRIBUTE_DIRECTORY);
    }
}

using utils::GetFilesWithExt;
using utils::crtDir;
